#!/usr/bin/python
import curses
from os import system

def get_param(prompt_string):
    screen.clear()
    screen.border(0)
    screen.refresh()
    input = screen.getstr(10, 10, 60)
    return input 

def execute_cmd(cmd_string):
    system("clear")
    a = system(cmd_string)
    print ""
    if a == 0:
        print "Command executed correctly"
    else:
        print "Command terminated with error"
    raw_input("Press enter")
    print ""

def main():
    #myscreen = curses.initscr()

    #myscreen.border(0)
    #myscreen.addstr(12, 25, "Python curses in action!")
    #myscreen.refresh()
    #myscreen.getch()

    #curses.endwin()

    x =0
    screen = curses.initscr()
    screen.clear()
    screen.addstr(2, 2, "Please enter a number...")
    screen.addstr(3, 4, "1 - Add a user")
    screen.addstr(4, 4, "2 - Restart Apache")
    screen.addstr(5, 4, "3 - Show disk space")
    screen.addstr(6, 4, "4 - Exit")
    screen.refresh()

    x = screen.getch()

    if x == ord('1'):
        username = get_param("Enter the Username")
        homedir = get_param("Enter the Passwd")
        curses.endwin()
        execute_cmd("aa" + username + homedir)
    if x == ord('2'):
        curses.endwin()
        execute_cmd("ls -l")
    if x == ord('3'):
        curses.endwin()
        execute_cmd("df -h")
    curses.endwin()

if __name__=="__main__":
    main()
